import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 22652
 * Date: 2024-06-16
 * Time: 14:07
 */
public class test_1 {
    public static void main(String[] args) {
        int[] arr = {2, 5, 1, 7, 10, 6, 9, 4, 3, 8};
        System.out.println(Arrays.toString(arr));
        Quick_Sort(arr,0,arr.length-1);
        System.out.println(Arrays.toString(arr));
    }

    private static void Quick_Sort(int[] arr,int start,int end) {
        if (start<end){
            int i =Quick_Sort_step(arr,start,end);
            Quick_Sort(arr,start,i-1);
            Quick_Sort(arr,i+1,end);
        }
    }

    private static int Quick_Sort_step(int[] arr, int start, int end) {
        int i=start,j=end;
        int tmp=arr[start];
        while (i!=j){
            while (arr[j]>=tmp&&j>i){
                j--;
            }
            arr[i]=arr[j];
            while (arr[i]<=tmp&&j>i){
                i++;
            }
            arr[j]=arr[i];
        }
        arr[i]=tmp;
        return i;
    }
}
